home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / amisl090.zip / AMITSRS.C < prev    next >
C/C++ Source or Header  |  1992-09-12  |  6KB  |  245 lines

  1. /************************************************************************/
  2. /*                                    */
  3. /* AMITSRS.C    List TSRs using the alternate multiplex interrupt    */
  4. /* Public Domain 1992 Ralf Brown                    */
  5. /* Version 0.90                             */
  6. /* Last Edit: 9/12/92                            */
  7. /*                                                                      */
  8. /* Must be compiled in a large data model (compact recommended)        */
  9. /* ex.  TCC -mc AMITSRS                            */
  10. /*                                    */
  11. /************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <dos.h>
  15. #include "amis.h"
  16.  
  17. char *scancodes[] =
  18.    {
  19.       0,        /* scan code 0 is "no key" */
  20.       "Esc",
  21.       "1",        /* scan code 2 */
  22.       "2",
  23.       "3",        /* scan code 4 */
  24.       "4",
  25.       "5",        /* scan code 6 */
  26.       "6",
  27.       "7",        /* scan code 8 */
  28.       "8",
  29.       "9",        /* scan code 10 */
  30.       "0",
  31.       "-",        /* scan code 12 */
  32.       "=",
  33.       "Backsp",        /* scan code 14 */
  34.       "Tab",
  35.       "Q",
  36.       "W",
  37.       "E",
  38.       "R",
  39.       "T",
  40.       "Y",
  41.       "U",
  42.       "I",
  43.       "O",
  44.       "P",        /* scan code 25 */
  45.       "[",
  46.       "]",
  47.       "Enter",
  48.       "Ctrl",
  49.       "A",
  50.       "S",
  51.       "D",
  52.       "F",
  53.       "G",
  54.       "H",
  55.       "J",
  56.       "K",
  57.       "L",
  58.       ";",
  59.       "'",        /* scan code 40 */
  60.       "`",
  61.       "LShift",
  62.       "\\",
  63.       "Z",
  64.       "X",
  65.       "C",
  66.       "V",
  67.       "B",
  68.       "N",
  69.       "M",
  70.       ",",
  71.       ".",
  72.       "/",        /* scan code 53 */
  73.       "RShift",
  74.       "*",
  75.       "Alt",
  76.       "Space",
  77.       "CapsLk",
  78.       "F1",
  79.       "F2",
  80.       "F3",
  81.       "F4",
  82.       "F5",
  83.       "F6",        /* scan code 64 */
  84.       "F7",
  85.       "F8",
  86.       "F9",
  87.       "F10",
  88.       "NumLk",
  89.       "ScrlLk",
  90.       "Home",
  91.       "Up",
  92.       "PgUp",        /* scan code 73 */
  93.       "Grey-",
  94.       "Left",
  95.       "KP5",
  96.       "Right",
  97.       "Grey+",
  98.       "End",
  99.       "Down",
  100.       "PgDn",        /* scan code 81 */
  101.       "Ins",
  102.       "Del",
  103.       "SysRq", 
  104.       0,
  105.       0,
  106.       "F11",        /* scan code 87 */
  107.       "F12",
  108.    } ;
  109.  
  110. /************************************************************************/
  111.  
  112. void display_hotkeys(int mpx_number)
  113. {
  114.    union REGS regs ;
  115.    char far *hotkeys ;
  116.    int num_hotkeys, hotkey_type ;
  117.    int shifts ;
  118.    
  119.    regs.h.ah = mpx_number ;
  120.    regs.h.al = AMIS_HOTKEYS ;    /* get hotkeys */
  121.    int86(0x2D,®s,®s) ;
  122.    if (regs.h.al == AMIS_SUCCESSFUL) /* supported? */
  123.       {
  124.       hotkeys = MK_FP(regs.x.dx,regs.x.bx) ;
  125.       hotkey_type = hotkeys[0] ;
  126.       num_hotkeys = hotkeys[1] ;
  127.       printf("%18s%d hotkey%s on ","",num_hotkeys,(num_hotkeys == 1)?"":"s") ;
  128.       if ((hotkey_type & HK_INT09ENTRY) || (hotkey_type & HK_INT09EXIT))
  129.      printf("INT 09h  ") ;
  130.       if ((hotkey_type & HK_INT15ENTRY) || (hotkey_type & HK_INT15EXIT))
  131.      printf("INT 15h") ;
  132.       printf("\n") ;
  133.       hotkeys += 2 ;        /* skip hotkey list header */
  134.       while (num_hotkeys-- > 0)
  135.      {
  136.      shifts = *((int far *)(hotkeys+1)) ;
  137.      printf("%22s","") ;
  138.      if ((shifts & HK_ANYCTRL) == HK_ANYCTRL)
  139.         printf("Ctrl-") ;
  140.      else if ((shifts & HK_BOTHCTRL) == HK_BOTHCTRL)
  141.         printf("Ctrl-Ctrl-") ;
  142.      else if ((shifts & HK_LCTRL) == HK_LCTRL)
  143.         printf("LCtrl-") ;
  144.      else if ((shifts & HK_RCTRL) == HK_RCTRL)
  145.         printf("RCtrl-") ;
  146.      if ((shifts & HK_ANYSHIFT) == HK_ANYSHIFT)
  147.         printf("Shift-") ;
  148.      else if ((shifts & HK_BOTHSHIFT) == HK_BOTHSHIFT)
  149.         printf("Shift-Shift-") ;
  150.      else if ((shifts & HK_LSHIFT) == HK_LSHIFT)
  151.         printf("LShift-") ;
  152.      else if ((shifts & HK_RSHIFT) == HK_RSHIFT)
  153.         printf("RShift-") ;
  154.      if ((shifts & HK_ANYALT) == HK_ANYALT)
  155.         printf("Alt-") ;
  156.      else if ((shifts & HK_BOTHALT) == HK_BOTHALT)
  157.         printf("Alt-Alt-") ;
  158.      else if ((shifts & HK_LALT) == HK_LALT)
  159.         printf("LAlt-") ;
  160.      else if ((shifts & HK_RALT) == HK_RALT)
  161.         printf("RAlt-") ;
  162.      if (shifts & HK_SCROLLOCK)
  163.         printf("ScrlLk-") ;
  164.      if (shifts & HK_NUMLOCK)
  165.         printf("NumLk-") ;
  166.      if (shifts & HK_CAPSLOCK)
  167.         printf("CapsLk-") ;
  168.      if (shifts & HK_SYSREQ)
  169.         printf("SysRq-") ;
  170.      if (scancodes[*hotkeys])
  171.         printf("%s",scancodes[*hotkeys]) ;
  172.      else
  173.         printf("nokey") ;
  174.      if (shifts & HK_SCRLLOCK_ON)
  175.         printf(" (ScrlLk on)") ;
  176.      if (shifts & HK_NUMLOCK_ON)
  177.         printf(" (NumLk on)") ;
  178.      if (shifts & HK_CAPSLOCK_ON)
  179.         printf(" (CapsLk on)") ;
  180.      printf("\n") ;
  181.      }
  182.       }
  183.    else
  184.       printf("%18sno hotkeys\n","") ;
  185.    return ;
  186. }
  187.  
  188. /************************************************************************/
  189.  
  190. int main(int argc,char **argv)
  191. {
  192.    int mpx ;
  193.    int did_banner = 0, verbose = 0 ;
  194.    union REGS regs ;
  195.    char far *sig ;
  196.    
  197.    /* prevent 'unused parameters' warnings */
  198.    (void)argv ;
  199.    /**/
  200.    /* if any commandline arguments, turn on verbose mode */
  201.    /**/
  202.    if (argc > 1)
  203.       verbose = 1 ;
  204.    /**/
  205.    /* loop through all 256 multiplex numbers, listing each signature we find */
  206.    /**/
  207.    for (mpx = 0 ; mpx <= 255 ; mpx++)
  208.       {
  209.       regs.h.ah = mpx ;
  210.       regs.h.al = AMIS_INSTCHECK ;  /* installation check */
  211.       int86(0x2D,®s,®s) ;
  212.       if (regs.h.al == AMIS_SUCCESSFUL) /* installed? */
  213.      {
  214.      if (!did_banner)
  215.         {
  216.         printf("Manufact  Product\t\tDescription\n") ;
  217.         printf("-------- -------- ----------------------------------------------\n") ;
  218.         did_banner = 1 ;
  219.         }
  220.      sig = MK_FP(regs.x.dx,regs.x.di) ;
  221.      printf("%8.8s %8.8s %.61s\n",sig,sig+8,sig+16) ;
  222.      /**/
  223.      /* if we were asked for a verbose display, also display TSR version */
  224.      /* and private API entry point (if present) on a second line         */
  225.      /**/
  226.      if (verbose)
  227.         {
  228.         printf("%18sversion %d.%02d","",regs.h.ch,regs.h.cl) ;
  229.         regs.h.ah = mpx ;
  230.         regs.h.al = AMIS_ENTRYPOINT ;  /* get private entry point */
  231.         int86(0x2D,®s,®s) ;
  232.         if (regs.h.al == AMIS_SUCCESSFUL)
  233.            printf("   entry point %04.4X:%04.4X ",regs.x.dx,regs.x.bx) ;
  234.         else
  235.            printf("   no private entry point") ;
  236.         printf("\n") ;
  237.         display_hotkeys(mpx) ;
  238.         }
  239.      }
  240.       }
  241.    if (!did_banner)
  242.       printf("No TSRs are using the alternate multiplex interrupt\n") ;
  243.    return 0 ;
  244. }
  245.